using UnityEngine;

namespace CinemaDirector
{
	[CutsceneItem("Light", "Set Intensity")]
	public class SetIntensityLight : CinemaActorEvent
	{
		public float Intensity;

		private float cachedIntensity;

		private float previousIntensity;

		public override void Initialize(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				previousIntensity = component.intensity;
				cachedIntensity = component.intensity;
			}
		}

		public override void Trigger(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				previousIntensity = component.intensity;
				component.intensity = Intensity;
			}
		}

		public override void Reverse(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				component.intensity = previousIntensity;
			}
		}

		public override void Stop(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				component.intensity = cachedIntensity;
			}
		}
	}
}
